<?php
/**
 * 重新生成缓存
 */
require_once(dirname(__FILE__) . '/config.php');
CheckPurview('sys_MakeHtml');

$file_config = DEDEDATA . '/config.cache.inc.php';
unlink($file_config);
ReWriteConfig();
if (!file_exists($file_config)) {
    echo "1、失败更新配置文件！\n";
} else {
    require(DEDEDATA . '/config.cache.inc.php');
    echo "1、成功更新配置文件！\n";
}

$file_pc_index = dirname(__FILE__) . '/../index.html';
unlink($file_pc_index);
require_once(DEDEINC . '/arc.partview.class.php');
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . '/demo/index.htm');
$pv->SaveToHtml($file_pc_index);
if (!file_exists($file_pc_index)) {
    echo "2、失败生成PC端主页HTML！\n";
} else {
    echo "2、成功生成PC端主页HTML！\n";
}

$file_mobile_index = dirname(__FILE__) . '/../m/index.html';
unlink($file_mobile_index);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . '/demo/index_m.htm');
$pv->SaveToHtml($file_mobile_index);
if (!file_exists($file_mobile_index)) {
    echo "3、失败生成移动端主页HTML！\n";
} else {
    echo "3、成功生成移动端主页HTML！\n";
}

require_once(DEDEINC . "/arc.listview.class.php");
$num = 0;
foreach ($cfg_Cs as $k => $v) {
    $lv = new ListView($k);
    if ($lv->TypeLink->TypeInfos['isdefault'] == -1) {
        //echo '这个类目是动态类目！';
        continue;
    }

    $return_url = $lv->MakeHtml();
    $num++;
}
if ($num) {
    echo "4、成功生成栏目HTML！数量：$num\n";
}

require_once(DEDEINC . "/arc.archives.class.php");
$dsql->Execute('out', "SELECT id FROM `#@__arctiny` WHERE arcrank = 0");
$num = 0;
while ($row = $dsql->GetObject('out')) {
    $ac = new Archives($row->id);
    $return_url = $ac->MakeHtml();
    $num++;
}
if ($num) {
    echo "5、成功生成文档HTML！数量：$num\n";
}
